Previous Book Contents Book Index Next

Inside Macintosh: QuickDraw GX Objects /
Chapter 4 - Colors and Color-Related Objects / Using Colors and Color-Related Objects


Assigning Colors to Shapes

Colors exist to affect the appearance of drawn shapes. QuickDraw GX shapes other than bitmaps and pictures get their color from the ink object that is part of the shape. One property of the ink object is color, a gxColor structure that describes the color of the associated shape.

To assign or change a shape's color, therefore, you typically call the GXSetInkColor function for the ink associated with the shape whose color you are assigning. You can also call GXSetShapeColor, which performs the same task but allows you the convenience of specifying the shape object involved, rather than the ink object that actually contains the color information. (Conversely, to inspect the color of a shape,
you call GXGetInkColor or GXGetShapeColor.) The GXSetInkColor, GXSetShapeColor, GXGetInkColor, and GXGetShapeColor functions are described in the chapter "Ink Objects" in this book.

Shapes that need more than one color are a special case. Bitmap shapes do not use the color information in their ink object. Instead, the color of each pixel in a bitmap shape
is specified as a pixel value in the gxBitmap structure; depending on the storage size
of each pixel, that pixel value may be an actual color value or it may be an index
into a color set. To set the color of an individual pixel in a bitmap, you call the GXSetShapePixel function, specifying which pixel to modify and what its new
color or new index value is. (Conversely, you can inspect the color of a pixel by
calling GXGetShapePixel.)

Modifying the color values in a color set, as described in the section "Manipulating the Colors in a Color Set Object" on page 4-47, is another way to change the color or colors of a shape. In a bitmap using indexed color space, any pixels whose indexes refer to color values you have modified will be changed in appearance, even though their pixel values remain unchanged. You can use this technique to perform simple manipulations of a shape's colors.

Bitmap shapes, the gxBitmap structure, and the functions GXSetShapePixel and GXGetShapePixel are described in the bitmap shapes chapter of Inside Macintosh: QuickDraw GX Graphics.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996